#pragma once

static int timedelta = 5000;//ms

static QDateTime fromSystemTime(const SYSTEMTIME&st) {
	return QDateTime(QDate(st.wYear,st.wMonth,st.wDay),QTime(st.wHour,st.wMinute,st.wSecond,st.wMilliseconds));
}

static inline bool operator <(const SYSTEMTIME &a,const SYSTEMTIME &b) {
	QDateTime da = fromSystemTime(a);
	QDateTime db = fromSystemTime(b);
	return da.toMSecsSinceEpoch()+timedelta < db.toMSecsSinceEpoch();
}
//compare with out millisecond
static  inline bool operator==(const SYSTEMTIME &a,const SYSTEMTIME &b) {
	QDateTime da = fromSystemTime(a);
	QDateTime db = fromSystemTime(b);
	return _abs64(da.toMSecsSinceEpoch()-db.toMSecsSinceEpoch())<timedelta;
}

static  inline bool operator >(const SYSTEMTIME &a,const SYSTEMTIME &b) {
	QDateTime da = fromSystemTime(a);
	QDateTime db = fromSystemTime(b);
	return da.toMSecsSinceEpoch()-timedelta > db.toMSecsSinceEpoch();
}

static  inline bool operator >=(const SYSTEMTIME &a,const SYSTEMTIME &b) {
	//bool iseq=
	//	memcmp((void*)&a,(void*)&b,sizeof(a))==0;
	return  a>b;
}

static inline bool AllEquel( FileNameTime & FN ) 
{
	return FN.creation==FN.access && FN.access==FN.entry && FN.entry==FN.modify;
}
